package com.xuecheng.content.api;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.xuecheng.content.mapper.CourseTeacherMapper;
import com.xuecheng.content.model.po.CourseTeacher;
import com.xuecheng.content.service.CourseTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "课程教师编辑接口",tags = "课程教师编辑接口")
@RestController
public class CourseTeacherController {

    @Autowired
    CourseTeacherService courseTeacherService;

    @ApiOperation("查询教师接口")
    @ApiImplicitParam(value = "courseId",name = "课程Id",required = true,dataType = "Long",paramType = "path")
    @GetMapping("/courseTeacher/list/{courseId}")
    public List<CourseTeacher> getTeachers(@PathVariable Long courseId){
      LambdaQueryWrapper<CourseTeacher> lambdaQueryWrapper=new LambdaQueryWrapper<CourseTeacher>();
      lambdaQueryWrapper.eq(CourseTeacher::getCourseId,courseId);
      return courseTeacherService.getTeacher(courseId);
    }

    @ApiOperation("添加教师接口")
    @ApiImplicitParam(value = "courseTeacher",name = "课程教师",required = true,dataType = "CourseTeacher",paramType = "body")
    @PostMapping("/courseTeacher")
    public CourseTeacher AddTeacher(@RequestBody CourseTeacher courseTeacher){
       return courseTeacherService.addTeacher(courseTeacher);
    }

    @ApiOperation("修改教师接口")
    @ApiImplicitParam(value = "courseTeacher",name = "课程教师",required = true,dataType = "CourseTeacher",paramType = "body")
    @PutMapping("/courseTeacher")
    public CourseTeacher updateTeacher(@RequestBody CourseTeacher courseTeacher){
        return courseTeacherService.updateTeacher(courseTeacher);
    }

    @ApiOperation("删除教师接口")
    @ApiImplicitParam(value = "courseId id",name = "课程id 教师id",required = true,dataType = "Long",paramType = "path")
    @DeleteMapping("/courseTeacher/course/{courseId}/{id}")
    public void deleteTeacher(@PathVariable Long courseId,@PathVariable Long id){
       courseTeacherService.deleteTeacher(courseId,id);
       return;
    }


}
